/*
 * Copyright 2010 Michael Nitsche
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.mnit.basis.swt.element;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Widget;


/**
 * @author Michael Nitsche
 */
public abstract class A_SWT_Element<TA extends A_SWT_Element<?,?>, TB extends Widget> extends A_SWT_Element_Basis<TA,TB> {

	public boolean gFreigegeben() {
		return swt().isDisposed();
	}

	public void freigeben() {
		swt().dispose();
	}

	public void eAuswahl(Listener aktion) {
		this.swt().addListener(SWT.Selection, aktion);
	}

	public void eFreigabe(Listener aktion) {
		this.swt().addListener(SWT.Dispose, aktion);
	}

	// ERZEUGEN

	protected final void init1() {
		init2();
	}

	protected final int style1() {
		return style2();
	}

	protected abstract int style2();
	protected abstract void init2();

}
